<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/28 0028
 * Time: 10:39
 */

namespace app\api\controller;

use app\admin\model\Accountdetail;

/**
 * Class Account
 * @package app\api\controller
 * 帐户信息、消费明细
 * 丁应清
 */
class Account extends BaseController
{
    /**
     * @return \think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * 消费明细
     */
    public function getAccountRecord()
    {
        $param = self::getHttpParam();
        if (empty($param->tenantId)) {
            return show(config('status.ERROR_STATUS'), self::NOT_PARAM, 'tenantId不能这空');
        } else if (empty($param->userId)) {
            return show(config('status.ERROR_STATUS'), self::NOT_PARAM, 'userId不能这空');
        } else {
            $tenantId = $param->tenantId;
            $userId = $param->userId;
            $accountDetail = Accountdetail::where(['tenantId' => $tenantId, 'userId' => $userId])->select();
            if (empty($accountDetail)) {
                return show(config('status.EMPTY_STATUS'), self::NOT_DATA, '未查到帐户明细');
            } else {
                return show(config('status.SUCCESS_STATUS'), self::MSG_SUCCESS, $accountDetail);
            }
        }
    }

}